﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.Date" %> 
<%@ page import="cn.ac.cintcm.dataconverge.util.Constants;"%>
<%@ include file="/WEB-INF/jsp/taglib.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>    
    <title><%=Constants.APP_TITLE %>--添加用户</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <link href="<%=basePath%>index/Themes/com/style.css" rel="stylesheet" type="text/css" />
    <script src="<%=basePath%>index/Scripts/Script.js" language="javascript" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
    <%@ include file="/WEB-INF/jsp/include/script.jsp" %>   
    <script language="JavaScript" type="text/JavaScript">
      function changeGraduateInfo(){
        var graduateInfo = document.getElementById("graduateInfo").value; 
      	if(graduateInfo =="s" || graduateInfo =="0"){
      		document.getElementById("schoolTime").style.display="none";
      	}else{
      	    document.getElementById("schoolTime").style.display="block";
      	}
      }
      
      function check(){
      var fm=document.forms[0];
      if(fm.id.value==""){
      alert("请填写ID!");
      fm.id.focus();
      return false;
      }else{
        var expID = new RegExp("^[0-9]*[a-z]*[A-Z]*_*$");
      var idValue=fm.id.value;
      if(idValue!=''&&!expID.test(idValue)){
      alert("id须为数字、字母和下划线的组合!");
      return false;
      }
      }
      
      if(fm.name.value==""){
      alert("请填写姓名!");
      fm.name.focus();
      return false;
      }
      if(fm.password.value==""){
      alert("请填写密码!");
      fm.password.focus();
      return false;
      }
      if(fm.password.value.length<6){
      alert("密码至少为6位！");
      fm.password.focus();
      return false;
      }
      
      if(fm.passworda.value==""){
      alert("请填写确认密码!");
      fm.passworda.focus();
      return false;
      }
      if(fm.password.value!=fm.passworda.value){
      fm.password.value="";
      fm.passworda.value="";
      alert("密码与确认密码不一致，请重新输入!");
      return false;
      }

 	  if(fm.org.value=="" ||fm.org.value=="0"){
      	alert("请填写单位信息!");
      	//fm.org.focus();
     	return false;
      }
      
      
      if(fm.idcard.value==""){
         alert("请填写您的身份证号码");
         fm.idcard.focus();
         return false;
         }
     
     if(fm.birthday.value==''){
				alert("请填写出生日期");
				fm.birthday.focus();
				return false;
		  } 
         
       var exp = new RegExp("^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$");
      var pvalue=document.all.birthday.value;
      if(pvalue!=''&&!exp.test(pvalue)){
      alert("请确认出生日期的格式!");
      document.all.birthday.focus();
	  return false;
	  }
      return true;
      }
      
      function cle(){
      document.all.admissionTime.value="";
      }
      function clea(){
      document.all.postNo.value="";
      }
      
    var xmlHttp;
  	var xmlDoc;
  	function createXMLHttpRequest() {
    	if (window.ActiveXObject) {
    		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	else if (window.XMLHttpRequest) {
        	xmlHttp = new XMLHttpRequest();                
    	}
	}
	function showUserDetails() {
	
  		var id = document.getElementById("id").value + "";
  		 var expID = new RegExp("^[0-9]*[a-z]*[A-Z]*_*$");
  		 var idValue=document.getElementById("id").value;
      if(idValue!=''&&!expID.test(idValue)){
      alert("登录帐号须为数字、字母和下划线的组合!");
      return;
      }
  		if(id!= "") {
  			createXMLHttpRequest();
    		xmlHttp.open("GET", "researcher.htm?action=checkId&id=" + id, true);
    		xmlHttp.onreadystatechange = callbackForShowUserDetails;
    		xmlHttp.send(null);
  		}
  	}
  	
  	function callbackForShowUserDetails(){
    	if(xmlHttp.readyState==4){
    		if(xmlHttp.status==200){
    			//clearResults();
    			parseMessage();
    		}
   		}
	}
	function parseMessage(){
	xmlDoc = xmlHttp.responseText;
	if(xmlDoc!='')
	alert(xmlDoc);
	}
	
	function changeOrg(){
		var orgId=document.getElementById("org").value + "";
		if(orgId!="0"){
			createXMLHttpRequest();
    		xmlHttp.open("GET", "subject.htm?action=getDepartments&orgId=" + orgId, true);
    		xmlHttp.onreadystatechange = callbackForDeps;
    		xmlHttp.send(null);
		}
	}
	
	function callbackForDeps(){
		if(xmlHttp.readyState==4){
    		if(xmlHttp.status==200){
    			parseDepMessage();
    		}
   		}
	}
	
	 function parseDepMessage(){
      		var xmlDoc = xmlHttp.responseXML;
			var nodes = xmlDoc.getElementsByTagName('department');
			var deps=document.getElementById("department");
			deps.length=1;
			deps.options[0]=new Option("请选择-----------","0")
			if(nodes!=null){
				var tid="";
				var name="";		
				for(var i=0;i<nodes.length;i++){
					tid=nodes[i].firstChild.firstChild.nodeValue;
					name=nodes[i].lastChild.firstChild.nodeValue;
					//alert("id is "+id+" name is "+name);
					deps.length++;
					deps.options[i+1]=new Option(name,tid);
					
				}
			}		
      }
    </script>
  </head>
 
<body  class="idt_body" scroll="yes"> 
  <form method="post" name="form0" action="researcher.htm?action=add&flag=add" onSubmit="return check();">
  <table cellpadding="0" cellspacing="0" width="100%" height="100%" id="Table8">
  
        <tr>
            <td  valign="top" height="100%">
                            <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="Table11">
                                <tr  id="ldTR">
                                    <td  valign="top">
                                        <!------------------ 标题栏 ------------------>
                                        <!--- 标题 ---->
                                        <table class="idt_tle_mg" cellspacing="0" cellpadding="0" width="100%">
                                            <tr  >
                                                <td class="idt_tle_i">
                                                    <img id="imgForm6" src="<%=basePath%>index/Themes/com/idt_tle_o.gif"></td>
                                                <td class="idt_tle_f1">
                                                   人员添加</td>
                                            </tr>
                                        </table>
      <div id="tdForm1">
             <table class="idt_fim_mg" cellspacing="1" cellpadding="0" width="100%" id="">
                 <tr id="tab1">
                     <td>
	   					<fieldset align="center">
			                <legend class="com_legend">登录信息 </legend>
			                <div id="Tr1" class="content">
			                    &nbsp;</div>
							<table  border="0" cellpadding="0" cellspacing="1" width="100%" class="com_fieldset_tab">
							   <tr>
							      <td class="fim_l" width="10%">登录帐号</td>
							      <td class="fim_r" width="40%" nowrap><input class="com_textbox" type="text" name="id" style="width:40%" value="${res.ida}"/><font color="red">*</font>
							      &nbsp;<input type="button" class="com_textbox" name="buttonq" value="检测帐号是否可用" onclick="showUserDetails();"/></td>
							      <td class="fim_l" width="10%">所属用户组</td>
							      <td class="fim_r">
							      <select id="group" name="group" style="70%">
								  <c:forEach items="${groupList}" var="group">
								  <option value="${group.groupid}" <c:if test="${res.group.groupid==group.groupid}">selected</c:if> ><c:out value="${group.groupname}"/></option>
								  </c:forEach>
								  </select>
								  </td>
							    </tr>
							    <tr>
							      <td class="fim_l">密码</td>
							      <td class="fim_r"><input class="com_textbox" type="password" name="password" maxlength="25"  style="70%"><font color="red">*</font></td>
							      <td class="fim_l">确认密码</td>
							      <td class="fim_r"><input class="com_textbox" type="password" name="passworda" maxlength="25"  style="70%"><font color="red">*</font></td>
							    </tr>
							     <tr>
							      <td class="fim_l">所在单位 </td>
							      <td class="fim_r">
							      <select id="org" name="org" onchange="changeOrg();" style="70%">
							      <option value="0">------请选择-----</option>
							      <c:forEach items="${orgList}" var="org">
								 		<option value="${org.id}" <c:if test="${res.org.id==org.id}">selected</c:if> ><c:out value="${org.name}"/></option>
								  </c:forEach>
								 	 </select><font color="red">*</font>
								  </td>
								   <td class="fim_l">所在部门 </td>
							      <td class="fim_r">
							      <select id="department" name="department" style="70%">
							       <option value="0">------请选择-----</option>
							       <c:forEach items="${departmentList}" var="department">
								 		<option value="${department.id}" <c:if test="${res.department.id==department.id}">selected</c:if>>
								 			<c:out value="${department.name}"/>
								 		</option>
								   </c:forEach>
								 </select>
								  </td>
							    </tr>
							</table>
     					</fieldset>
				   </td>
				  </tr>
				  
				    <tr id="tab1">
                     <td>
	   					<fieldset align="center">
			                <legend class="com_legend">基本信息 </legend>
			                <div id="Tr1" class="content">
			                    &nbsp;</div>
							<table  border="0" cellpadding="0" cellspacing="1" width="100%" class="com_fieldset_tab">  
							  <tr>
							      <td class="fim_l" width="10%">姓名</td>
							      <td class="fim_r" width="40%"><input class="com_textbox" type="text" name="name" style="width:95%" value="${res.name}"><font color="red">*</font></td>
							       <td class="fim_l" width="10%">性别</td>
							      <td class="fim_r">
								  	<select name="sex" style="width:95%">
								  	    <option value="0">------请选择-----</option>
								 		<option value="2" <c:if test="${res.sex==2}">selected</c:if> >男</option>
								  		<option value="1" <c:if test="${res.sex==1}">selected</c:if> >女</option>
								  	</select>
								  </td>
								  </tr>
								  <tr><td class="fim_l">身份证号</td>
								  <td class="fim_r" nowrap><input class="com_textbox" type="text" style="width:95%" name="idcard" value="${res.idcard}"/>
								   <font color="red">*</font></td>
								  </tr>
								  <tr>
								      <td class="fim_l">出生日期</td>
								   
							      <td class="fim_r" nowrap>
								  	<input name="birthday" class="com_textbox" type="text" value="${res.dateString}" style="width:95%" onFocus="WdatePicker({el:'birthday',dateFmt:'yyyy-MM-dd'})"/>
								    <font color="red">*</font>
								  </td>
								  <td class="fim_l">是否在读研究生</td>
							       <td class="fim_r" nowrap>
							       <select id="graduateInfo" name="graduateInfo" style="width:40%" onchange="changeGraduateInfo()">
							             <option value="0">------请选择-----</option>
								  		<option value="s" <c:if test="${res.graduateInfo=='s'}">selected</c:if>>不是在读研究生</option>
										<option value="d" <c:if test="${res.graduateInfo=='d'}">selected</c:if>>在读硕士</option>
										<option value="e" <c:if test="${res.graduateInfo=='e'}">selected</c:if>>在读博士</option>
								      </select>
								      <span id="schoolTime" style="display:none">
								      <select id="admissionTime" name="admissionTime" <c:if test="${res.graduateInfo=='s'}">style="display:none;" </c:if><c:if test="${res.graduateInfo!='s'}">style="display:block;" </c:if>>
								      <option value="0">请选择入学年份</option>
								      <%java.util.Date date2=new java.util.Date();
									      int year2=date2.getYear()+1900;
									      int begin=year2-10;%>
								      <c:forEach  var="i" begin="<%=begin%>" end="<%=year2%>" step="1">
								      <option value="${i}" <c:if test="${res.admissionTime==i}">selected</c:if> ><c:out value="${i}"/>年入学</option>
								      </c:forEach>
								      </select>
								      </span>
								  </td>
							    </tr>
							    <tr>
							      
							      <td class="fim_l">毕业院校</td>
							      <td class="fim_r"><input class="com_textbox" name="graduateIns" style="width:95%" value="${res.graduateIns}"/></td>
							
							      <td class="fim_l">专业</td>
							      <td class="fim_r"><input class="com_textbox" name="major" style="width:95%" type="text" value="${res.major}"/>
							      </td>      
							    </tr>
							    <tr>
							      <td class="fim_l">院重点学科</td>
							      <td class="fim_r"><select name="keySubject" style="width:95%">
							             <option value="0">------请选择------</option>     
							                  
							            <c:forEach items="${majorList}" var="key">
							      		<option value="${key.keySubject}" <c:if test="${res.keySubject==key.keySubject}">selected</c:if> ><c:out value="${key.keySubject}"/>(<c:out value="${key.name}"/>)</option>
							      		</c:forEach> 
							      		<option value="其它" <c:if test="${res.keySubject=='其它'}">selected</c:if>>其它</option>  
							      		 		
							          </select>
							      </td>
							      
							      <td class="fim_l">学科角色</td>
							      <td class="fim_r">
							        <select name="position" style="width:95%">
							             <option value="0">------请选择-----</option>
							                   
								  		<option value="1" <c:if test="${res.position=='1'}">selected</c:if>>学术带头人</option>
								  		<option value="2" <c:if test="${res.position=='2'}">selected</c:if>>学科带头人</option>
										<option value="3" <c:if test="${res.position=='3'}">selected</c:if>>参与人员</option>
										 
								 	  </select>
							      </td>
							      </tr>
							      <tr>
								  <td class="fim_l">职称</td>
								  
							      <td class="fim_r">
							         <select name="zhicheng" style="width:95%">
							          <option value="0">------请选择-----</option>
								  		<option value="1" <c:if test="${res.zhicheng=='1'}">selected</c:if>>正高</option>
								  		<option value="2" <c:if test="${res.zhicheng=='2'}">selected</c:if>>副高</option>
										<option value="3" <c:if test="${res.zhicheng=='3'}">selected</c:if>>中级</option>
										<option value="4" <c:if test="${res.zhicheng=='4'}">selected</c:if>>初级</option>
										<option value="5" <c:if test="${res.zhicheng=='5'}">selected</c:if>>其他</option>
								 	  </select>
								  </td> 
								  <td class="fim_l">学位</td>
							      <td class="fim_r"><select name="qualification" style="width:95%">
							       <option value="0">------请选择-----</option>
								  		<option value="1" <c:if test="${res.qualification=='1'}">selected</c:if>>本科</option>
								  		<option value="2" <c:if test="${res.qualification=='2'}">selected</c:if>>硕士</option>
										<option value="3" <c:if test="${res.qualification=='3'}">selected</c:if>>博士</option>
										<option value="4" <c:if test="${res.qualification=='4'}">selected</c:if>>博士后</option>
										<option value="5" <c:if test="${res.qualification=='5'}">selected</c:if>>中专</option>
										<option value="6" <c:if test="${res.qualification=='6'}">selected</c:if>>大专</option>
										<option value="7" <c:if test="${res.qualification=='7'}">selected</c:if>>其它</option>
								 	  </select></td>
							    </tr>
							</table>
     					</fieldset>
				   </td>
				  </tr>
				  
				  
				    <tr id="tab1">
                     <td>
	   					<fieldset align="center">
			                <legend class="com_legend">联系方式 </legend>
			                <div id="Tr1" class="content">
			                    &nbsp;</div>
							<table  border="0" cellpadding="0" cellspacing="1" width="100%" class="com_fieldset_tab">
							  <tr>
							      <td class="fim_l" width="10%">通信地址 </td>
							      <td class="fim_r"  width="40%"><input class="com_textbox" name="address" style="width:95%" value="${res.address}"/></td>
							      <td class="fim_l"  width="10%">邮编</td>
							      <td class="fim_r"><input class="com_textbox" name="postNo" style="width:95%" value="${res.postNo}"></td>
							    </tr>
							    <tr>
							      <td class="fim_l">固定电话/院分机号</td>
							      <td class="fim_r"><input class="com_textbox" name="officePhone" style="width:95%" value="${res.officePhone}"></td>
								  <td class="fim_l">传真</td>
							      <td class="fim_r"><input class="com_textbox" name="fax" style="width:95%" value="${res.fax}"></td>
							    </tr>
							    <tr>
							      <td class="fim_l">移动电话</td>
							      <td class="fim_r"><input class="com_textbox" name="cellphone" style="width:95%" value="${res.cellphone}"/></td>
							       <td class="fim_l">邮件地址</td>
							      <td class="fim_r"><input class="com_textbox" name="email" style="width:95%" value="${res.email}"></td>
							    </tr>
							</table>
     					</fieldset>
				   </td>
				  </tr>
  </table>
  <table cellspacing="0" cellpadding="0" width="100%" class="idt_bottom_mg" border="0">
        <tr>
            <td align="right">
                <input  class="com_btn2" id="Button1" name="save" type="submit" value="保存">&nbsp;&nbsp;&nbsp;&nbsp;
               <input type="button" value="取消" name="B4" class="com_btn2" id="Button2" onclick="javascript:window.close();">
            </td>
        </tr>
    </table>                               

<br>
      </table>
            </td>
        </tr>
    </table></form>
  </body>
</html>
